package com.yunxi.service.dubboService.impl.basedata;

import com.github.pagehelper.PageInfo;
import com.yunxi.basedata.pojo.FactoryVO;
import com.yunxi.basedata.service.FactoryDubboService;
import com.yunxi.model.basedata.Factory;
import com.yunxi.service.localService.basedata.FactoryService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

/**
 * <p>
 * 工厂信息 服务实现类
 * </p>
 *
 * @author 
 * @since 2019-05-29
 */
public class FactoryDubboServiceImpl implements FactoryDubboService {

    @Autowired
    @Qualifier(value = "factoryServiceImpl")
    FactoryService factoryService;


    @Override
    public FactoryVO getById(String id) throws InvocationTargetException, IllegalAccessException {
    Factory factory = factoryService.getById(id);
    FactoryVO factoryVO = new FactoryVO();
        BeanUtils.copyProperties(factory,factoryVO);
        return factoryVO;
    }

    @Override
    public void saveOrUpdate(FactoryVO factoryVO) throws InvocationTargetException, IllegalAccessException {
    Factory factory = new Factory();
        BeanUtils.copyProperties(factoryVO,factory);
    factoryService.saveOrUpdate(factory);
    }

    @Override
    public void removeById(String id) {
    factoryService.removeById(id);
    }

    @Override
    public PageInfo<FactoryVO> findPageByVO(FactoryVO factoryVO, Integer pageNum, Integer pageSize) throws InvocationTargetException, IllegalAccessException {
      PageInfo<FactoryVO> pageInfo = factoryService.pageByVo(factoryVO,pageNum,pageSize);
      return pageInfo;
   }

    @Override
    public void removeByListVo(List<FactoryVO> factoryVOList) throws IllegalAccessException, InvocationTargetException, InstantiationException {
        factoryService.removeByListVo(factoryVOList);
    }

    @Override
    public List<FactoryVO> findListByVo(FactoryVO factoryVO) {
        return factoryService.listByVo(factoryVO);
    }
}
